package com.example.zhaohang.employmentapp;

import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.example.zhaohang.weigit.MyVideoView;
import com.example.zhaohang.weigit.OnFinishListener;
import com.example.zhaohang.weigit.ProgressView;

public class SplashActivity extends AppCompatActivity {

    private MyVideoView    mSplashVidoview;
    private ProgressView mProgressView;
    private TextView mTextView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        mProgressView = (ProgressView) findViewById(R.id.progressview);
        mSplashVidoview = (MyVideoView) findViewById(R.id.splash_vidoview);
        mTextView = (TextView) findViewById(R.id.text);
        mSplashVidoview.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video));
        //播放
        mSplashVidoview.start();
        //循环播放
        mSplashVidoview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {

                mSplashVidoview.start();


            }
        });



        //跳过的点击事件
        mProgressView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                startActivity(new Intent(SplashActivity.this,MainActivity.class));
                finish();
            }
        });

        //设置进度条颜色
        mProgressView.setPaintColor("#ff0000");
        //开始倒计时
        mProgressView.startDownTime(6000, new OnFinishListener() {
            @Override
            public void onFinish() {
                startActivity(new Intent(SplashActivity.this,MainActivity.class));
                finish();
            }
        });

//        mTextView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                startActivity(new Intent(SplashActivity.this,MainActivity.class));
//                finish();
//            }
//        });
    }
}
